package com.crane.common.core.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author lt
 * @date 2020/8/28
 */
public class BCryptUtil {
    private static final BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();

    /**
     * 密码加密
     *
     * @param password
     * @return
     */
    public static String encode(String password) {
        return bCryptPasswordEncoder.encode(password);
    }

    /**
     * 密码校验
     *
     * @param inPwd  输入密码
     * @param curPwd 当前密码
     * @return
     */
    public static boolean matchPwd(String inPwd, String curPwd) {
        return bCryptPasswordEncoder.matches(inPwd, curPwd);
    }
    
    public static void main(String[] args) {
		System.out.println(BCryptUtil.encode("123456"));
	}
}
